#include <iostream>
#include <vector>
using namespace std;

const int N = 2e5 + 10;

vector<int> a(N);

int main()
{
	int t; cin >> t;
	while(t--)
	{
		a.clear();
		int n; cin >> n;
		a.push_back(-1e9);
		for(int i = 1; i <= n; i++)
		{
			int x; cin >> x;
			if(a.back() != x) a.push_back(x);
		}
		a.push_back(-1e9);
		int ans = 0;
		for(int i = 1; i < a.size() - 1; i++)
		{
			if(a[i] > a[i - 1] && a[i] > a[i + 1]) ans++;
		}
		cout << ans << endl;
	}
	
	return 0;
}
